package com.example.qts.base;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

public abstract class BaseObserver<T> implements Observer<T> {
    public BaseModel model;
    public Disposable disposable;
    public BaseObserver(BaseModel baseModel){
        this.model=baseModel;
    }
    public void onSubscribe(Disposable disposable1){
        this.disposable=disposable1;
        model.addDisposable(disposable1);
    }
    public void onNext(T t){
        onSuccess(t);
        disposable.dispose();
        model.removedisaposable(disposable);
    }
    protected abstract void onSuccess(T t);
    public void onError(Throwable e){
        onFali(e.getMessage());
    }

    protected abstract void onFali(String error);
}
